package com.linkhub.oms.admin.modules.order.domain.param;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

/**
 * @Description: OrderAddressUpdateParam
 * @Author: echo
 * @Date: 2024/4/3 16:52
 * @Version: 1.0
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class OrderAddressUpdateParam extends BaseSingleOrderParam implements Serializable {


    @ApiModelProperty(value = "收件人", required = true)
    @NotBlank(message = "{validation.address.name.notBlank}")
    @Length(max = 100, message = "{validation.address.name.length}")
    private String name;

    @ApiModelProperty(value = "电话")
    @Length(max = 100, message = "{validation.address.other.length}")
    private String phone;

    @ApiModelProperty(value = "城市")
    @Length(max = 100, message = "{validation.address.other.length}")
    private String city;

    @ApiModelProperty(value = "邮编")
    @Length(max = 100, message = "{validation.address.other.length}")
    private String zip;

    @ApiModelProperty(value = "省份")
    @Length(max = 100, message = "{validation.address.other.length}")
    private String province;

    @ApiModelProperty(value = "国家")
    @Length(max = 100, message = "{validation.address.other.length}")
    private String country;

    @ApiModelProperty(value = "地址1")
    @Length(max = 200, message = "{validation.address.length}")
    private String address1;

    @ApiModelProperty(value = "地址2")
    @Length(max = 200, message = "{validation.address.length}")
    private String address2;

    @ApiModelProperty(value = "公司")
    @Length(max = 200, message = "{validation.address.company.length}")
    private String company;

    @ApiModelProperty("国家变更标识")
    private boolean countryChangedFlag;

    @ApiModelProperty("国家简码")
    private String countryCode;

    public OrderAddressUpdateParam resetNullIfBlank() {
        OrderAddressUpdateParam param = new OrderAddressUpdateParam();
        param.setSysOrderId(this.getSysOrderId());
        param.setName(StringUtils.defaultIfBlank(this.getName(), null));
        param.setPhone(StringUtils.defaultIfBlank(this.getPhone(), null));
        param.setCity(StringUtils.defaultIfBlank(this.getCity(), null));
        param.setZip(StringUtils.defaultIfBlank(this.getZip(), null));
        param.setProvince(StringUtils.defaultIfBlank(this.getProvince(), null));
        param.setCountry(StringUtils.defaultIfBlank(this.getCountry(), null));
        param.setAddress1(StringUtils.defaultIfBlank(this.getAddress1(), null));
        param.setAddress2(StringUtils.defaultIfBlank(this.getAddress2(), null));
        param.setCompany(StringUtils.defaultIfBlank(this.getCompany(), null));

        return param;

    }


}
